import time

import pyglet

import mode
import resources


class LevelTransition(mode.Mode):
    name = "level_transition"

    def __init__(self, level_name=None):
        self.window = None
        self.level = level_name

    def connect(self, control):
        # Inherits window from controller
        self.control = control
        self.window = control.window

        resources.play_music("level.mp3", self.control.musicplayer)

    def disconnect(self):
        #self.control.musicplayer.pause()
        pass

    def update(self, dt):
        #time.sleep(1) # Or do some fading out
        self.control.switch_handler("game", self.level)

mode.modes["level_transition"] = LevelTransition
